/**
 * @file TeachingQualitySystem.vue
 * @description 教学质量智能评估系统，提供基于AI的教学质量多维度评估
 * @created 2025-04-17
 */

<template>
  <div class="quality-system-container">
    <div class="header-section">
      <h1>教学质量智能评估系统</h1>
      <p class="description">基于多维数据构建智能评估模型，提供客观、全面的教学质量分析</p>
      
      <div class="filter-section">
        <div class="filter-item">
          <span>学院：</span>
          <select v-model="selectedCollege">
            <option value="all">全部学院</option>
            <option v-for="college in colleges" :key="college.id" :value="college.id">
              {{ college.name }}
            </option>
          </select>
        </div>
        <div class="filter-item">
          <span>学期：</span>
          <select v-model="selectedSemester">
            <option value="current">当前学期</option>
            <option value="last">上一学期</option>
            <option value="year">本学年</option>
          </select>
        </div>
        <button class="search-btn" @click="generateReport">生成评估报告</button>
      </div>
    </div>

    <!-- 评估概览 -->
    <div class="overview-section">
      <h2>教学质量评估概览</h2>
      <div class="quality-overview">
        <div class="quality-score">
          <div class="score-circle" :style="{ background: `conic-gradient(#1890ff ${overallScore * 3.6}deg, #f0f0f0 0deg)` }">
            <div class="score-inner">{{ overallScore }}</div>
          </div>
          <div class="score-label">总体评分</div>
        </div>
        
        <div class="quality-indicators">
          <div v-for="(indicator, index) in qualityIndicators" 
               :key="index" 
               class="indicator-item">
            <div class="indicator-label">{{ indicator.label }}</div>
            <div class="indicator-bar">
              <div class="bar-fill" :style="{ width: `${indicator.score}%`, backgroundColor: getColorByScore(indicator.score) }"></div>
            </div>
            <div class="indicator-score">{{ indicator.score }}</div>
          </div>
        </div>
      </div>
    </div>

    <!-- 评估维度详情 -->
    <div class="details-section">
      <div class="section-header">
        <h2>多维度评估详情</h2>
        <div class="dimension-tabs">
          <div v-for="tab in dimensionTabs" 
               :key="tab.id"
               :class="['tab', { active: activeDimension === tab.id }]"
               @click="activeDimension = tab.id">
            {{ tab.name }}
          </div>
        </div>
      </div>

      <!-- 教学内容质量 -->
      <div v-if="activeDimension === 'content'" class="dimension-content">
        <div class="content-quality">
          <div class="chart-container">
            <h3>教学内容质量评分分布</h3>
            <v-chart class="chart" :option="contentQualityOption" />
          </div>
          <div class="analysis-card">
            <h3>AI分析</h3>
            <div class="analysis-content">
              <p>教学内容质量整体表现良好，有89%的课程教学内容质量评分在80分以上。</p>
              <p>存在问题：部分专业基础课程内容更新不够及时，与行业最新发展有所脱节。</p>
              <p>优势领域：计算机科学、生物技术、金融工程等专业的专业课内容质量评分较高。</p>
            </div>
          </div>
        </div>
      </div>

      <!-- 教学方法 -->
      <div v-if="activeDimension === 'method'" class="dimension-content">
        <div class="teaching-methods">
          <div class="methods-comparison">
            <h3>教学方法效果对比</h3>
            <v-chart class="chart" :option="teachingMethodOption" />
          </div>
          <div class="analysis-card">
            <h3>AI分析</h3>
            <div class="analysis-content">
              <p>混合式教学和项目式学习在学生满意度和学习效果方面表现最佳。</p>
              <p>传统讲授法在基础理论课程中仍有其优势，但互动性不足。</p>
              <p>建议：对尚未采用新型教学方法的教师提供专项培训，促进教学方法多样化。</p>
            </div>
          </div>
        </div>
      </div>

      <!-- 学生评价 -->
      <div v-if="activeDimension === 'feedback'" class="dimension-content">
        <div class="student-feedback">
          <div class="feedback-sentiment">
            <h3>学生评价情感分析</h3>
            <v-chart class="chart" :option="feedbackSentimentOption" />
          </div>
          <div class="word-cloud-container">
            <h3>评价关键词</h3>
            <div class="word-cloud">
              <div v-for="(word, index) in keywords" 
                   :key="index"
                   class="keyword"
                   :style="{ 
                     fontSize: word.size + 'px',
                     color: word.type === 'positive' ? '#52c41a' : word.type === 'negative' ? '#f5222d' : '#1890ff',
                     fontWeight: word.weight
                   }">
                {{ word.text }}
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 学习效果 -->
      <div v-if="activeDimension === 'effect'" class="dimension-content">
        <div class="learning-effect">
          <div class="chart-container">
            <h3>学习效果指标</h3>
            <v-chart class="chart" :option="learningEffectOption" />
          </div>
          <div class="analysis-card">
            <h3>AI分析</h3>
            <div class="analysis-content">
              <p>整体学习效果良好，在知识掌握度和能力提升两个维度表现突出。</p>
              <p>创新思维和实践应用能力有待提高，建议增加更多实践环节和开放性问题。</p>
              <p>不同专业学习效果差异较大，需针对性开展教学改进工作。</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 改进建议 -->
    <div class="improvement-section">
      <h2>AI教学改进建议</h2>
      <div class="improvement-cards">
        <div v-for="(suggestion, index) in improvementSuggestions" 
             :key="index" 
             class="suggestion-card">
          <div class="card-header">
            <div class="priority-indicator" :class="suggestion.priority"></div>
            <h3>{{ suggestion.title }}</h3>
          </div>
          <div class="card-body">
            <p>{{ suggestion.content }}</p>
          </div>
          <div class="card-footer">
            <div class="target">适用对象：{{ suggestion.target }}</div>
            <button class="action-btn">采纳建议</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import VChart from 'vue-echarts'

// 筛选条件
const colleges = ref([
  { id: 1, name: '计算机科学与技术学院' },
  { id: 2, name: '经济与金融学院' },
  { id: 3, name: '工学院' },
  { id: 4, name: '医学院' },
  { id: 5, name: '文学院' }
])
const selectedCollege = ref('all')
const selectedSemester = ref('current')

// 总体评分
const overallScore = ref(86)

// 质量指标
const qualityIndicators = ref([
  { label: '教学内容', score: 88 },
  { label: '教学方法', score: 84 },
  { label: '学生满意度', score: 90 },
  { label: '学习效果', score: 82 },
  { label: '资源配套', score: 85 }
])

// 根据分数获取颜色
const getColorByScore = (score) => {
  if (score >= 90) return '#52c41a'
  if (score >= 80) return '#1890ff'
  if (score >= 70) return '#faad14'
  return '#f5222d'
}

// 生成评估报告
const generateReport = () => {
  // 实际应用中这里会调用API获取数据
  console.log('生成评估报告', selectedCollege.value, selectedSemester.value)
}

// 评估维度标签页
const dimensionTabs = ref([
  { id: 'content', name: '教学内容' },
  { id: 'method', name: '教学方法' },
  { id: 'feedback', name: '学生评价' },
  { id: 'effect', name: '学习效果' }
])
const activeDimension = ref('content')

// 教学内容质量图表配置
const contentQualityOption = ref({
  title: { text: '教学内容质量分布' },
  tooltip: { trigger: 'axis' },
  xAxis: {
    type: 'category',
    data: ['90-100', '80-89', '70-79', '60-69', '<60']
  },
  yAxis: { type: 'value' },
  series: [{
    data: [42, 47, 9, 2, 0],
    type: 'bar',
    barWidth: '40%',
    itemStyle: {
      color: function(params) {
        const colors = ['#52c41a', '#1890ff', '#faad14', '#fa8c16', '#f5222d']
        return colors[params.dataIndex]
      }
    }
  }]
})

// 教学方法效果图表配置
const teachingMethodOption = ref({
  radar: {
    indicator: [
      { name: '学生满意度', max: 100 },
      { name: '知识掌握', max: 100 },
      { name: '课堂参与', max: 100 },
      { name: '能力提升', max: 100 },
      { name: '学习兴趣', max: 100 }
    ]
  },
  legend: {
    data: ['传统讲授', '混合式教学', '项目式学习', '翻转课堂']
  },
  series: [{
    type: 'radar',
    data: [
      {
        value: [75, 85, 65, 70, 60],
        name: '传统讲授',
        areaStyle: {}
      },
      {
        value: [85, 80, 90, 85, 90],
        name: '混合式教学',
        areaStyle: {}
      },
      {
        value: [80, 75, 95, 90, 95],
        name: '项目式学习',
        areaStyle: {}
      },
      {
        value: [90, 80, 85, 75, 85],
        name: '翻转课堂',
        areaStyle: {}
      }
    ]
  }]
})

// 学生评价情感分析图表配置
const feedbackSentimentOption = ref({
  tooltip: {
    trigger: 'item'
  },
  legend: {
    orient: 'vertical',
    left: 'left'
  },
  series: [
    {
      name: '评价情感分布',
      type: 'pie',
      radius: '70%',
      data: [
        { value: 65, name: '正面评价', itemStyle: { color: '#52c41a' } },
        { value: 20, name: '中性评价', itemStyle: { color: '#1890ff' } },
        { value: 15, name: '负面评价', itemStyle: { color: '#f5222d' } }
      ],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
})

// 关键词云数据
const keywords = ref([
  { text: '生动', size: 30, type: 'positive', weight: 'bold' },
  { text: '清晰', size: 28, type: 'positive', weight: 'bold' },
  { text: '有趣', size: 26, type: 'positive', weight: 'bold' },
  { text: '互动', size: 24, type: 'positive', weight: 'normal' },
  { text: '实用', size: 22, type: 'positive', weight: 'normal' },
  { text: '条理', size: 20, type: 'positive', weight: 'normal' },
  { text: '难度适中', size: 18, type: 'positive', weight: 'normal' },
  { text: '热情', size: 20, type: 'positive', weight: 'normal' },
  { text: '案例丰富', size: 18, type: 'positive', weight: 'normal' },
  { text: '进度快', size: 22, type: 'negative', weight: 'normal' },
  { text: '作业多', size: 20, type: 'negative', weight: 'normal' },
  { text: '抽象', size: 18, type: 'negative', weight: 'normal' },
  { text: '实践少', size: 20, type: 'negative', weight: 'normal' },
  { text: '枯燥', size: 18, type: 'negative', weight: 'normal' },
  { text: '专业', size: 24, type: 'neutral', weight: 'normal' },
  { text: '严谨', size: 22, type: 'neutral', weight: 'normal' },
  { text: '系统', size: 20, type: 'neutral', weight: 'normal' }
])

// 学习效果图表配置
const learningEffectOption = ref({
  tooltip: { trigger: 'axis' },
  radar: {
    indicator: [
      { name: '知识掌握度', max: 100 },
      { name: '能力提升', max: 100 },
      { name: '学习持久性', max: 100 },
      { name: '创新思维', max: 100 },
      { name: '实践应用', max: 100 }
    ]
  },
  series: [{
    type: 'radar',
    data: [
      {
        value: [85, 82, 75, 68, 70],
        name: '整体学习效果',
        areaStyle: {
          color: 'rgba(24, 144, 255, 0.2)'
        },
        lineStyle: {
          color: '#1890ff'
        }
      }
    ]
  }]
})

// 改进建议
const improvementSuggestions = ref([
  {
    title: '增强课程内容实时更新机制',
    content: '建议建立专业课程内容季度更新机制，特别是计算机、人工智能等发展迅速的学科，确保教学内容与行业最新发展同步。',
    priority: 'high',
    target: '全校专业课程'
  },
  {
    title: '推广混合式教学模式',
    content: '针对评估结果，混合式教学模式在学生满意度和学习效果方面表现最佳，建议在更多课程中推广该模式，并提供相关培训支持。',
    priority: 'high',
    target: '传统教学方法为主的课程'
  },
  {
    title: '优化实践教学环节',
    content: '学生反馈中"实践少"是较为突出的负面评价，建议增加实验、项目、案例等实践教学环节比重，提升学生实践应用能力。',
    priority: 'medium',
    target: '理论课程占比过高的专业'
  },
  {
    title: '调整课程作业设计',
    content: '部分课程"作业多"但效果不佳，建议采用"少而精"原则，设计更有挑战性和创新性的综合作业，减少机械性作业数量。',
    priority: 'medium',
    target: '工科和理科基础课程'
  }
])
</script>

<style scoped>
.quality-system-container {
  padding: 20px;
  background-color: #f0f2f5;
  min-height: 100vh;
}

.header-section {
  margin-bottom: 30px;
}

.header-section h1 {
  font-size: 28px;
  color: #1890ff;
  margin-bottom: 10px;
}

.description {
  color: #666;
  margin-bottom: 20px;
}

.filter-section {
  display: flex;
  gap: 20px;
  align-items: center;
  background-color: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.filter-item {
  display: flex;
  align-items: center;
}

.filter-item span {
  margin-right: 8px;
}

.filter-item select {
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #d9d9d9;
  min-width: 150px;
}

.search-btn {
  padding: 0 20px;
  height: 32px;
  background-color: #1890ff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.overview-section {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 30px;
}

.overview-section h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 18px;
}

.quality-overview {
  display: flex;
  gap: 30px;
}

.quality-score {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.score-inner {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: bold;
  color: #1890ff;
}

.score-label {
  margin-top: 10px;
  font-size: 16px;
  color: #666;
}

.quality-indicators {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.indicator-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.indicator-label {
  width: 80px;
  text-align: right;
}

.indicator-bar {
  flex: 1;
  height: 8px;
  background-color: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
}

.indicator-score {
  width: 30px;
  text-align: right;
  font-weight: bold;
}

.details-section {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 30px;
  overflow: hidden;
}

.section-header {
  padding: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.section-header h2 {
  margin: 0 0 15px;
  font-size: 18px;
}

.dimension-tabs {
  display: flex;
  gap: 10px;
}

.tab {
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s;
}

.tab:hover {
  background-color: #f9f9f9;
}

.tab.active {
  background-color: #e6f7ff;
  color: #1890ff;
  font-weight: bold;
}

.dimension-content {
  padding: 20px;
}

.content-quality, .teaching-methods, .student-feedback, .learning-effect {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 20px;
}

.chart-container, .methods-comparison, .feedback-sentiment {
  height: 350px;
}

.chart {
  height: 100%;
  width: 100%;
}

.analysis-card {
  background-color: #f9f9f9;
  padding: 20px;
  border-radius: 8px;
  height: 350px;
}

.analysis-card h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 16px;
  color: #1890ff;
}

.analysis-content p {
  margin-bottom: 10px;
  line-height: 1.5;
}

.word-cloud-container {
  background-color: #f9f9f9;
  padding: 20px;
  border-radius: 8px;
  height: 350px;
  overflow: auto;
}

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.keyword {
  margin: 5px;
  display: inline-block;
  padding: 3px;
}

.improvement-section {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.improvement-section h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 18px;
}

.improvement-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.suggestion-card {
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  padding: 15px;
  background-color: #f9f9f9;
  display: flex;
  align-items: center;
  gap: 10px;
}

.priority-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.priority-indicator.high {
  background-color: #f5222d;
}

.priority-indicator.medium {
  background-color: #faad14;
}

.priority-indicator.low {
  background-color: #52c41a;
}

.card-header h3 {
  margin: 0;
  font-size: 16px;
}

.card-body {
  padding: 15px;
}

.card-body p {
  margin: 0;
  line-height: 1.5;
  color: #666;
}

.card-footer {
  padding: 15px;
  background-color: #f9f9f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.target {
  font-size: 14px;
  color: #888;
}

.action-btn {
  padding: 5px 10px;
  background-color: #1890ff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.action-btn:hover {
  background-color: #40a9ff;
}
</style> 